{block:style}
<style>
    .card-body .title {
        padding-top: .5rem;
        padding-bottom: .8rem;
    }

    .cms-info-box{
        height: 40px;
        min-height: auto;
        box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
    }
    .info-box .info-box-content {
        padding: 0;
    }
    .cms-info-box:hover{
        box-shadow: 0 0 1px rgba(0,0,0,.225), 0 1px 3px rgba(0,0,0,.3);
    }
    .cms-info-box a:hover {
        color: #333333;
    }
    .add-admin-panel{
        cursor: pointer;
    }
    .a-btn{
        color: #666;
    }
    .a-btn:hover{
        color: #666;
    }
    .table {
        font-size: 13px;
    }
    .table th{
        text-align: right;
        font-weight: normal;
    }
    .layui-layer-loading .layui-layer-loading1 {
        width: 180px !important;
        padding-top: 40px;
        margin-left: -30px;
        text-align: center;
        background: url("/static/libs/layer/theme/admin/loading-1.gif") no-repeat center top !important;
    }
    .hkcmsiframe {
        width: 100%;
        height: 100%;
        min-height: 320px;
    }
</style>
{/block:style}

<!--快速导航-->
<div class="card card-primary">
    <div class="card-body">
        <div class="title">
            <span><i class="fas fa-bars"></i> {:__('Quick navigation')}</span>
        </div>
        <div class="row mt-2">
            {volist name="nav_list" id="n"}
            <div class="col-xs-6 col-md-2">
                <div class="info-box cms-info-box">
                    <a href="{:url('/'.(!empty($n['route'])?$n['route']:$n['name']))}" class="a-btn info-box-content col-12 btn-newMenu" data-is_nav="true" data-id="{$n.auth_rule_id}" id="nav-item-{$n.auth_rule_id}" data-title="{:__($n.title)}">
                        <span class="text-center">{:__($n.title)}</span>
                    </a>
                </div>
            </div>
            {/volist}
            <div class="col-2">
                <div class="info-box cms-info-box">
                    <div class="info-box-content col-12 add-admin-panel">
                        <span class="text-center"><i class="fas fa-plus"></i></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--系统信息-->
<div class="card card-primary">
    <div class="card-body">
        <div class="title">
            <span><i class="fas fa-cog"></i> {:__('System information')}</span>
        </div>
        <div class="pb-3 mt-2">
            <table class="table table-bordered">
                <colgroup>
                    <col width="150">
                    <col width="40%">
                    <col width="150">
                    <col>
                </colgroup>
                <tr>
                    <th>{:__('Site name')}</th>
                    <td>{$site.title}</td>
                    <th>{:__('Current version')}</th>
                    <td>v{:config('ver.cms_version')}.{:config('ver.cms_build')}</td>
                </tr>
                <tr>
                    <th>{:__('System update')}</th>
                    <td>
                        <a href="#" target="_blank" class="upgrade_url text-primary" style="display: none"></a>
                        <span class="upgrade"></span>
                    </td>
                    <th>{:__('Business license')}</th>
                    <td>
                        <a href="https://www.hkcms.cn/index/index/authorize" target="_blank"><span class="authorize text-primary">免授权，永久商用</span></a>
                    </td>
                </tr>
            </table>
        </div>
        <div class="title">
            <span><i class="fas fa-server"></i> {:__('Server information')}</span>
        </div>
        <div class="mt-2">
            <table class="table table-bordered">
                <colgroup>
                    <col width="150">
                    <col width="40%">
                    <col width="150">
                    <col>
                </colgroup>
                <tr>
                    <th>{:__('Server system')}</th>
                    <td>{$system_info['OS']}</td>
                    <th>{:__('Server domain name')}</th>
                    <td>{$system_info['domain']}</td>
                </tr>
                <tr>
                    <th>{:__('Server environment')}</th>
                    <td>{$system_info['running_system']}</td>
                    <th>{:__('PHP version')}</th>
                    <td>{$system_info['phpv']}</td>
                </tr>
                <tr>
                    <th>{:__('Database version')}</th>
                    <td>{$system_info['mysqlv']}</td>
                    <th>{:__('GD version')}</th>
                    <td>{$system_info['gdv']}</td>
                </tr>
            </table>
        </div>
    </div>
</div>

<div class="card card-primary">
    <div class="card-body iframe-con" style="padding: 0.5rem">
    </div>
</div>

{block:script}
<script>
    require(['jquery','layer'], function ($, Layer) {
        $(function () {

            // 插入官方动态、问答
            $('.iframe-con').html('<iframe class="hkcmsiframe" src="http://www.hkcms.cn/index/index/notice" frameborder="no"></iframe>');

            $('.add-admin-panel').click(function () {
                cmsOpen('{:url("/auth.AdminPanel/add",["popup"=>1])}','{:__("Add")}',{ type: 2});
            })

            // 更新检测
            function upgrade() {
                $.ajax({
                    url:'{:url("/index/upgrade")}',
                    success:function (result){
                        if (result.data.upgrade==1) {
                            $('.upgrade').hide();
                            $('.upgrade_url').attr('href', result.data.url);
                            $('.upgrade_url').attr('data-v', result.data.v);
                            $('.upgrade_url').html(lang('New version v%s detected',[result.data.v]));
                            $('.upgrade_url').show();
                        } else if (result.data.upgrade==-1) {
                            if (result.data.p) {
                                $('.upgrade').hide();
                                $('.upgrade_url').show();
                                $('.upgrade_url').attr('href', result.data.url);
                                $('.upgrade_url').attr('data-p', result.data.p);
                                $('.upgrade_url').attr('data-v', result.data.v);
                                $('.upgrade_url').html(lang('There are new patches [%s]',[result.data.p]));
                            } else {
                                $('.upgrade').show();
                                $('.upgrade_url').hide();
                                $('.upgrade').html("{:__('Your HkCms is already up-to-date.')}");
                            }
                        } else {
                            $('.upgrade').html(result.msg);
                        }
                    }
                });
            }
            upgrade();

            // 更新
            $('.upgrade_url').click(function (e) {
                var url = $(this).attr('href');
                cmsOpen(url, lang('Upgrade'), {
                    type:2,
                    btn: [lang('Upgrade'),lang('Cancel')],
                    btnAlign: 'c',
                    yes: function(index, layero){
                        //询问框
                        layer.confirm(lang('Confirm')+'?', {
                            btn: [lang('Confirm'),lang('Cancel')] //按钮
                        }, function(){
                            var idx = layer.msg('{:__("Updating, please do not close the page.")}', {
                                icon: 16
                                ,shade: 0.3
                                ,time: false
                            });
                            $.ajax({
                                type: 'post',
                                url:'{:url("/index/upgrade")}',
                                data:{p: $('.upgrade_url').data('p'), v: $('.upgrade_url').data('v')},
                                success:function (result){
                                    layer.close(idx)
                                    if (result.code==200) {
                                        layer.msg(result.msg, {time: 1000}, function (e) {
                                            parent.window.location.reload();
                                        });
                                    } else {
                                        layer.alert(result.msg);
                                    }
                                }
                            })
                        });
                    }})
                e.preventDefault()
            });
        })
    })
</script>
{/block:script}